<template>
  <div class="section">
    <h2>输入SQL日志</h2>
    <div class="example">
      <h3>输入示例：</h3>
      <code>2025-07-04 19:46:57.919 [thread] DEBUG com.example.Mapper - ==> Preparing: SELECT * FROM users WHERE id = ? AND name = ?</code><br>
      <code>2025-07-04 19:46:57.944 [thread] DEBUG com.example.Mapper - ==> Parameters: 123(Integer), john(String)</code><br><br>
    </div>
    <textarea
      :value="value"
      @input="$emit('input', $event.target.value)"
      placeholder="请粘贴SQL日志内容..."
    ></textarea>
    <br><br>
    <button class="btn" @click="$emit('parse')">解析SQL</button>
    <!-- <button class="btn btn-secondary" @click="$emit('load-sample')">加载示例</button> -->
    <button class="btn btn-execute" @click="$emit('direct-execute')">直接运行SQL语句</button>
    <button class="btn btn-er-diagram" @click="$emit('generate-er-diagram')">📊 AI生成数据库表ER图</button>
  </div>
</template>

<script>
export default {
  name: 'InputSection',
  props: {
    value: {
      type: String,
      default: ''
    }
  }
}
</script>

<style scoped>
.example {
  background: #e0f2fe;
  border: 1px solid #0284c7;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 20px;
}

.example h3 {
  color: #0369a1;
  margin-bottom: 10px;
}

.example code {
  background: #e0f2fe;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

textarea {
  width: 100%;
  min-height: 200px;
  padding: 20px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.3s ease;
  background: #f9fafb;
}

textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(79, 70, 229, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.btn-secondary:hover {
  box-shadow: 0 5px 15px rgba(107, 114, 128, 0.3);
}

.btn-execute {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-execute:hover {
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

.btn-er-diagram {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.btn-er-diagram:hover {
  box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3);
}

@media (max-width: 768px) {
  .btn {
    padding: 12px 20px;
    font-size: 14px;
  }
}
</style>